package training_process.TraningI_III;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * Author by KyrieC
 * Created by sheting on 2023/11/21
 */// Press Shift twice to open the Search Everywhere dialog and type `show whitespaces`,
// then press Enter. You can now see whitespace characters in your code.
public class Main {
    public static void main(String[] args) {
        int lNum;
        int rNum;
        OP[] ops = OP.values(); // 获得计算符号枚举数组
        OP op;
        Random random = new Random();
        List<Equation> equations = new ArrayList<>();

        // 得到50个符合题目要求的计算式
        for (int i = 0; i < 50; i++ ) {
            do {
                lNum = random.nextInt(100) + 1; // 获得随机数[0,100]
                rNum = random.nextInt(100) + 1; // 获得随机数[0,100]
                op = ops[random.nextInt(ops.length)]; // 获得计算符号枚举数组中的随机
            } while ((lNum + rNum > 100) || (lNum - rNum < 0)); // 和>100或差<0会再次循环
            equations.add(new Equation(lNum, rNum, op)); // 将符合条件的计算式添加到集合
        }

        // 按一定格式输出50个计算式
        int cnt = 1;
        System.out.println(equations.size());
        for (Equation equation : equations) {
            if (cnt % 6 == 0) {
                System.out.print("(" + cnt + ")" + equation+"   ");
                System.out.println("");
            } else {
                System.out.print("(" + cnt + ")" + equation+"   ");
            }
            cnt++;
        }
    }

}